package com.AC.ACShunfeng;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * 赏金猎人
 */
public class test2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<int[]> list = new ArrayList<>();
        for(int i = 0; i<n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int[] arr = new int[]{a,b,c};
            list.add(arr);
        }
        sc.close();
        System.out.println(maxProfit(list));
    }

    public static int maxProfit(List<int[]> list){
        PriorityQueue<int[]> queue = new PriorityQueue<>((a,b) ->{
           if(a[0] == b[0])
               return b[2] - a[2];
           else
               return a[0] - b[0];
        });
        int res = 0;
        for(int[] arr : list){
            queue.offer(arr);
        }
        while(!queue.isEmpty()){
            int[] cur = queue.poll();
            if(!queue.isEmpty()){
                //如果没有冲突，则直接可以加
                if(cur[1] < queue.peek()[0]){
                    res += cur[2];
                }else{
                    //既然肯定有冲突，那么就选冲突里面利润最大的时间段
                    int curMax = cur[2];
                    int curMaxEnd = cur[1];
                    while(!queue.isEmpty() && queue.peek()[0] <= curMaxEnd){
                        if(curMax < queue.peek()[2]){
                            curMax = queue.peek()[2];
                            curMaxEnd = queue.peek()[1];
                        }
                        queue.poll();
                    }
                    res += curMax;
                }
            }else{
                res += cur[2];
            }
        }
        return res;
    }

    @Test
    public void test(){
        int[] a1 = {1,3,5};
        int[] a2 = {2,7,3};
        int[] a3 = {5,10,1};
        int[] a4 = {6,11,50};
        int[] a5 = {7,10,25};
        int[] a6 = {11,13,10};
        List<int[] > list = new ArrayList<>();
        list.add(a1);list.add(a2);list.add(a3);
        list.add(a4);list.add(a5);list.add(a6);
        System.out.println(maxProfit(list));
    }
}
